package cn.dongqihong.framework.util;

import java.net.MalformedURLException;
import java.net.URL;

/**
 * URL工具类
 * Created by DongQihong on 2016/11/25.
 */
public class UrlUtil {

    /**
     * 提取URL中的域名
     *
     * @param url url
     * @return 域名
     */
    public static String extractHost(String url) {
        try {
            URL urlObject = new URL(url);
            String host = urlObject.getHost();
            return host;
        } catch (MalformedURLException e) {
            return "";
        }
    }
}
